<!--
 * @Description: 模板打印功能示例组件模板文件
 * @Author: HuiSir<https://gitee.com/huisir001>
 * @Date: 2025-09-23 10:52:28
 * @LastEditTime: 2025-10-15 17:12:06
-->
<template>
  <el-button type="primary" @click="print">点击打印</el-button>
</template>

<script lang="ts" setup>
// vue3-vite 组件模板字符串导入方式，此处为卡片组件模板字符串
import TplPrint from "@/utils/TplPrint";

// 配置项
defineOptions({ name: "TplPrint", isFull: true });

// 右键菜单-关闭标签
const print = async () => {
  // 动态导入组件节省内存
  const { default: TplComp } = await import("./tpl.vue");

  // 打印卡片组件
  TplPrint({
    component: TplComp,
    props: {
      personInfo: {
        name: "张三",
        gender: "男",
        age: "45",
        outpatientNum: "OP20231001",
        department: "消化内科",
        height: "175cm",
        weight: "70kg",
        bmi: "22.9",
      },
      surveyData: {
        q1: "否",
        q2: "是",
        q3: "是",
        q4: "是",
        q5: "否",
        q6: "否",
      },
      result: {
        advice:
          "建议增加每日牛奶摄入量，确保充足的钙元素摄入；同时增加每日液体摄入量，保持身体水分平衡。",
      },
      footerInfo: {
        doctor: "李医生",
        date: new Date().toLocaleString(),
      },
    },
  });
};
</script>
